﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using System.Windows;
using MVVM.ViewModels;

namespace MVVM.Commands
{
    public class CustomCommand : ICommand
    {
        private bool canExecute;
        public event EventHandler CanExecuteChanged;

        private Names viewModel;

        public CustomCommand(Names viewModel)
        {
            this.viewModel = viewModel;
        }
        //public CustomCommand()
        //{

        //}

        public bool CanExecute(object parameter)
        {
            //bool canExecuteNow = (parameter != null) && (parameter.ToString() != string.Empty);

            //if (canExecute != canExecuteNow)
            //{
            //    canExecute = canExecuteNow;
            //    if (CanExecuteChanged != null)
            //    {
            //        CanExecuteChanged(this, new EventArgs());
            //    }
            //}
            return true;
            return canExecute;
        }

        public void Execute(object parameter)
        {
            string name = parameter.ToString();
            if (name != null && string.IsNullOrEmpty(name) != true)
            {
                this.viewModel.NamesModel.AddName(name);

            }
            MessageBox.Show("printing: " + parameter.ToString());
        }
    }
}
